/*
 * $Id: scm.h,v 1.4 2006-07-14 11:17:28 bacon Exp $
 */

#ifndef _XP_MSW_SCM_H_
#define _XP_MSW_SCM_H_

#include <xp/types.h>
#include <xp/macros.h>
#include <xp/msw/svc.h>

typedef struct xp_scm_t xp_scm_t;

struct xp_scm_t
{
	void* handle;
	int errnum;
	xp_bool_t __dynamic;
};

enum
{
	XP_SCM_ENOERR, /* no error */
	XP_SCM_EACCDN, /* access denied */
	XP_SCM_EDEPRN, /* dependent service running */
	XP_SCM_EINHND, /* invalid handle */
	XP_SCM_EINPAR, /* invalid parameter */
	XP_SCM_EINSVC, /* invalid service control */
	XP_SCM_EINNAM, /* invalid service name */
	XP_SCM_ENOACC, /* service cannot accept control code */
	XP_SCM_ENOACT, /* service not active */
	XP_SCM_ETMOUT, /* request timed out */
	XP_SCM_ESHTDN, /* system is shutting down */
	XP_SCM_ENOSVC, /* the service does not exist */
	XP_SCM_ESVCMD, /* service has already been marked for deletion */
	XP_SCM_ENODAB, /* no such database */
	XP_SCM_ENOPTH, /* path not found */
	XP_SCM_ESVCRN, /* service is already running */

	XP_SCM_EDBLCK, /* database locked */
	XP_SCM_EDEPDL, /* depending service missing or deleted */
	XP_SCM_EDEPFL, /* depending service failed to start */
	XP_SCM_EDSABL, /* service disabled */
	XP_SCM_ELOGON, /* service start-up failure due to logon failure */
	XP_SCM_ENOTHR, /* thread failure */

	XP_SCM_EEXIST, /* service exists */
	XP_SCM_EDUPNM  /* duplicate service name */
};

#ifdef __cplusplus
extern "C" {
#endif

xp_scm_t* xp_scm_open (xp_scm_t* scm, const xp_char_t* host);
int xp_scm_close (xp_scm_t* scm);

int xp_scm_geterrnum (xp_scm_t* scm);
const xp_char_t* xp_scm_geterrstr (xp_scm_t* scm);

int xp_scm_createsvc (xp_scm_t* scm, 
	const xp_char_t* name, const xp_char_t* path, 
	int svc_type, int start_type);

int xp_scm_deletesvc (xp_scm_t* scm, const xp_char_t* name);
int xp_scm_startsvc (xp_scm_t* scm, const xp_char_t* name);
int xp_scm_stopsvc (xp_scm_t* scm, const xp_char_t* name);
int xp_scm_pausesvc (xp_scm_t* scm, const xp_char_t* name);
int xp_scm_resumesvc (xp_scm_t* scm, const xp_char_t* name);
int xp_scm_getsvcstatus (xp_scm_t* scm, const xp_char_t* name, xp_svcstatus_t* status);

#ifdef __cplusplus
}
#endif

#endif
